const validateMoble = (rule, value, callback) => {
  if (value == '') {
    rule.message = '请输入手机号'
    callback(new Error('请输入手机号'))
  } else if (!/^(?:(?:\+|00)86)?1[3456789]\d{9}$/.test(value)) {
    rule.message = '请输入正确的手机号'
    callback(new Error('请输入正确的手机号'))
  } else {
    callback()
  }
}
const validatePhone = (rule, value, callback) => {
  if (value == '') {
    rule.message = '请输入座机号'
    callback(new Error('请输入座机号'))
  } else if (!/^0[0-9-]{10,13}$/.test(value)) {
    rule.message = '请输入正确的座机号'
    callback(new Error('请输入正确的座机号'))
  } else {
    callback()
  }
}
//验证身份证方法
const validateIDCard = (id) => {
  var reg = /^\d{17}(\d|X|x)$/
  if (!reg.test(id)) {
    return false
  }
  var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
  var codeArr = id.split('')
  var sum = 0
  for (var i = 0; i < 17; i++) {
    sum += parseInt(codeArr[i]) * factor[i]
  }
  var checkDigit = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
  var checkCode = checkDigit[sum % 11]
  return codeArr[17].toUpperCase() === checkCode
}
//验证身份证
const validateID = (rule, value, callback) => {
  if (value == '') {
    rule.message = '请输入身份证号'
    callback(new Error('请输入身份证号'))
  } else if (!validateIDCard(value)) {
    rule.message = '请输入正确的身份证号'
    callback(new Error('请输入正确的身份证号'))
  } else {
    callback()
  }
}
const validateIP = (rule, value, callback) => {
  if (value == '') {
    rule.message = '请输入IP地址'
    callback(new Error('请输入IP地址'))
  } else if (!/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(value)) {
    rule.message = '请输入正确的IP地址'
    callback(new Error('请输入正确的IP地址'))
  } else {
    callback()
  }
}
export default [
  {
    name: 'XM',
    type: 'input',
    label: '姓名',
    rules: {
      required: true
    }
  },
  {
    name: 'mc',
    type: 'input',
    label: '名称',
    rules: {
      required: true
    }
  },
  {
    name: 'key',
    type: 'input',
    label: '参数名称',
    rules: {
      required: true
    }
  },
  {
    name: 'value',
    type: 'input',
    label: '参数值',
    rules: {
      required: true
    }
  },
  {
    name: 'sm',
    type: 'input',
    label: '参数说明',
    rules: {
      required: true
    }
  },
  {
    name: 'ip',
    type: 'input',
    label: '设备ip',
    rules: {
      required: true,
      validator: validateIP
    }
  },
  {
    name: 'sbm',
    type: 'input',
    label: '设备名称',
    rules: {
      required: true
    }
  },
  {
    name: 'apkName',
    type: 'input',
    label: 'APK名称',
    rules: {
      required: true
    }
  },
  {
    name: 'APKNAME',
    type: 'input',
    label: 'APK名称',
    rules: {
      required: true
    }
  },
  {
    name: 'FILENAME',
    type: 'input',
    label: '文件名称',
    rules: {
      required: true
    }
  },
  {
    name: 'PACKAGENAME',
    type: 'input',
    label: '包名',
    rules: {
      required: true
    }
  },
  {
    name: 'APKTYPEMC',
    type: 'input',
    label: 'APK类型',
    rules: {
      required: true
    }
  },
  {
    name: 'KFFACTORYMC',
    type: 'input',
    label: 'APK开发公司',
    rules: {
      required: true
    }
  },
  {
    name: 'COMPANYMC',
    type: 'input',
    label: 'APK适合终端',
    rules: {
      required: true
    }
  },
  {
    name: 'YWFZMC',
    type: 'input',
    label: '业务分组',
    rules: {
      required: true
    }
  },
  {
    name: 'VERSION',
    type: 'input',
    label: '版本号',
    rules: {
      required: true
    }
  },
  {
    name: 'ADDTIME',
    type: 'input',
    label: '上传时间',
    rules: {
      required: true
    }
  },

  {
    name: 'yynr',
    type: 'textarea',
    label: '语音内容',
    rules: {
      required: true
    },
    attrs: {
      rows: 6
    }
  },
  {
    name: 'hdmc',
    type: 'input',
    label: '活动名称',
    rules: {
      required: true
    }
  },

  {
    name: 'price',
    type: 'input',
    label: '单价',
    append: '元/斤'
  },
  {
    name: 'inventory',
    type: 'input',
    label: '库存'
    // append: [
    //   {
    //     label: '套',
    //     value: 'tao'
    //   },
    //   {
    //     label: '件',
    //     value: 'jian'
    //   }
    // ]
  }
]
